package com.pw.study.realtime.app

import org.apache.spark.SparkConf
import org.apache.spark.streaming.StreamingContext

abstract class BaseAPP {
  //初始化参数
  var appName: String = "baseApp"
  var master: String = "local[4]"
  var batchDuration: Int = 10
  var groupName: String = "baseGroup"
  var conf = new SparkConf().set("spark.testing.memory", "4718592000").setMaster(master)
  var context: StreamingContext = null

  def runApp(code: => Unit): Unit = {
    try {
      //计算逻辑
      code
      context.start()
      context.awaitTermination()
    } catch {
      case ex: Exception => {
        ex.printStackTrace()
        throw new RuntimeException("运行时异常。。。。。")
      }
    }
  }

}
